<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<head>
    <th:block th:include="include :: header('物料库存列表')"/>
</head>
<body class="gray-bg">
<div class="container-div">
    <div class="row">
        <div class="col-sm-12 search-collapse">
            <form id="formId">
                <div class="select-list">
                    <ul>
                        <li>
                            <label>入库单号：</label>
                            <input type="text" name="entryOrderId"/>
                        </li>
                        <li>
                            <label>物料编号：</label>
                            <input type="text" name="materialId"/>
                        </li>
                        <li>
                            <label>库存数量：</label>
                            <input type="text" name="entryNum"/>
                        </li>
                        <li>
                            <label>单价：</label>
                            <input type="text" name="unitPrice"/>
                        </li>
                        <li>
                            <label>产地：</label>
                            <input type="text" name="producer"/>
                        </li>
                        <li>
                            <label>品牌：</label>
                            <input type="text" name="brand"/>
                        </li>
                        <li>
                            <label>备注：</label>
                            <input type="text" name="remarks"/>
                        </li>
                        <li>
                            <label>税额：</label>
                            <input type="text" name="taxAmount"/>
                        </li>
                        <li>
                            <label>入库时间：</label>
                            <input type="text" class="time-input" placeholder="请选择入库时间" name="entryTime"/>
                        </li>
                        <li>
                            <label>供应商：</label>
                            <select name="supplierId" class="supplier-select"></select>
                        </li>
                        <li>
                            <a class="btn btn-primary btn-rounded btn-sm" onclick="$.table.search()"><i
                                    class="fa fa-search"></i>&nbsp;搜索</a>
                            <a class="btn btn-warning btn-rounded btn-sm" onclick="$.form.reset()"><i
                                    class="fa fa-refresh"></i>&nbsp;重置</a>
                        </li>
                    </ul>
                </div>
            </form>
        </div>

        <div class="btn-group-sm" id="toolbar" role="group">
            <a class="btn btn-success" onclick="$.operate.add()" shiro:hasPermission="warehouse:materialInventory:add">
                <i class="fa fa-plus"></i> 添加
            </a>
            <a class="btn btn-primary single disabled" onclick="$.operate.edit()"
               shiro:hasPermission="warehouse:materialInventory:edit">
                <i class="fa fa-edit"></i> 修改
            </a>
            <a class="btn btn-danger multiple disabled" onclick="$.operate.removeAll()"
               shiro:hasPermission="warehouse:materialInventory:remove">
                <i class="fa fa-remove"></i> 删除
            </a>
            <a class="btn btn-warning" onclick="$.table.exportExcel()"
               shiro:hasPermission="warehouse:materialInventory:export">
                <i class="fa fa-download"></i> 导出
            </a>
        </div>
        <div class="col-sm-12 select-table table-striped">
            <table id="bootstrap-table"></table>
        </div>
    </div>
</div>
<th:block th:include="include :: footer"/>
<th:block th:include="include :: select2-css" />
<th:block th:include="include :: select2-js" />
<script th:inline="javascript">
    $('.supplier-select').select2({
        placeholder: '--请选择供应商--',
        ajax: {
            url: '/warehouse/supplier/selectList',
            delay: 250,
            data: function (params) {
                return {
                    supplierName: params.term
                };
            }
        }
    });

    var editFlag = [[${@permission.hasPermi('warehouse:materialInventory:edit')}]];
    var removeFlag = [[${@permission.hasPermi('warehouse:materialInventory:remove')}]];
    var prefix = ctx + "warehouse/materialInventory";

    $(function () {
        var options = {
            url: prefix + "/list",
            createUrl: prefix + "/add",
            updateUrl: prefix + "/edit/{id}",
            removeUrl: prefix + "/remove",
            exportUrl: prefix + "/export",
            modalName: "物料库存",
            columns: [{
                checkbox: true
            }, {
                field: 'entryOrderId',
                title: '入库单号'
            }, {
                field: 'materialName',
                title: '物料名称'
            }, {
                field: 'materialId',
                title: '物料编号'
            }, {
                field: 'entryNum',
                title: '库存数量'
            }, {
                field: 'unitPrice',
                title: '单价'
            }, {
                field: 'unit',
                title: '单位'
            }, {
                field: 'producer',
                title: '产地'
            }, {
                field: 'brand',
                title: '品牌'
            }, {
                field: 'remarks',
                title: '备注'
            }, {
                field: 'entryTime',
                title: '入库时间'
            }, {
                field: 'supplierName',
                title: '供应商'
            }, {
                title: '操作',
                align: 'center',
                formatter: function (value, row, index) {
                    var actions = [];
                    actions.push('<a class="btn btn-success btn-xs ' + editFlag + '" href="javascript:void(0)" onclick="$.operate.edit(\'' + row.id + '\')"><i class="fa fa-edit"></i>编辑</a> ');
                    actions.push('<a class="btn btn-danger btn-xs ' + removeFlag + '" href="javascript:void(0)" onclick="$.operate.remove(\'' + row.id + '\')"><i class="fa fa-remove"></i>删除</a>');
                    return actions.join('');
                }
            }]
        };
        $.table.init(options);
    });
</script>
</body>
</html>